1
00:00:01,320 --> 00:00:03,164
So, we connected our application

2
00:00:03,164 --> 00:00:07,200
with the database using Mongoose in the last lecture.

3
00:00:07,200 --> 00:00:10,559
But wait, what actually is Mongoose?

4
00:00:10,559 --> 00:00:15,050
Well, Mongoose is an object data modeling library

5
00:00:15,050 --> 00:00:17,320
for MongoDB and Node JS,

6
00:00:17,320 --> 00:00:20,950
providing a higher level of abstraction.

7
00:00:20,950 --> 00:00:22,770
So, it's a bit like the relationship

8
00:00:22,770 --> 00:00:24,840
between Express and Node,

9
00:00:24,840 --> 00:00:28,990
so Express is a layer of abstraction over regular Node,

10
00:00:28,990 --> 00:00:31,700
while Mongoose is a layer of abstraction

11
00:00:31,700 --> 00:00:34,490
over the regular MongoDB driver.

12
00:00:34,490 --> 00:00:37,700
And by the way, an object data modeling library

13
00:00:37,700 --> 00:00:40,450
is just a way for us to write JavaScript code

14
00:00:40,450 --> 00:00:43,750
that will then interact with a database.

15
00:00:43,750 --> 00:00:47,010
So, we could just use a regular MongoDB driver

16
00:00:47,010 --> 00:00:50,710
to access our database, and it would work just fine,

17
00:00:50,710 --> 00:00:52,740
but instead we use Mongoose,

18
00:00:52,740 --> 00:00:56,670
because it gives us a lot more functionality out of the box,

19
00:00:56,670 --> 00:00:59,490
allowing for faster and simpler development

20
00:00:59,490 --> 00:01:01,180
of our applications.

21
00:01:01,180 --> 00:01:03,510
So, some of the features Mongoose give us

22
00:01:03,510 --> 00:01:07,450
is schemas to model our data and relationship,

23
00:01:07,450 --> 00:01:11,100
easy data validation, a simple query API,

24
00:01:11,100 --> 00:01:13,725
middleware, and much more.

25
00:01:13,725 --> 00:01:17,580
In Mongoose, a schema is where we model our data,

26
00:01:17,580 --> 00:01:20,640
so where we describe the structure of the data,

27
00:01:20,640 --> 00:01:23,440
default values, and validation.

28
00:01:23,440 --> 00:01:27,740
We then take that schema and create a model out of it.

29
00:01:27,740 --> 00:01:30,010
And the model is basically a wrapper

30
00:01:30,010 --> 00:01:33,320
around the schema, which allows us to actually interface

31
00:01:33,320 --> 00:01:37,470
with the database in order to create, delete, update,

32
00:01:37,470 --> 00:01:38,713
and read documents.

33
00:01:39,600 --> 00:01:43,340
All right, so this was just a very quick introduction.

34
00:01:43,340 --> 00:01:44,730
Now, let's actually go ahead

35
00:01:44,730 --> 00:01:47,503
and create a simple schema and model.


